class Solution:
    def isPalindrome(self, s: str) -> bool:
        mid_word = ""
        for word in s:
            if word.isalpha() or word.isdecimal():
                mid_word += word.lower()
        # print(mid_word)
        return mid_word == mid_word[::-1]


a = Solution()
print(a.isPalindrome("A man, a plan, a canal: Panama"))
print(a.isPalindrome("race a car"))
print(a.isPalindrome(""))
